package com.artezio.buyndrive.dao.impl;

import com.artezio.buyndrive.dao.CountryDAO;
import com.artezio.buyndrive.domain.Carservice;
import com.artezio.buyndrive.domain.Country;
import com.artezio.buyndrive.domain.Users;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Expression;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
public class CountryDAOImpl extends AbstractHibernateDao<Country> 
    implements CountryDAO{
    
    @Autowired
    private SessionFactory sessionFactory;
    
    public CountryDAOImpl() {
        super.setSessionFactory(sessionFactory);
    }

    @Override
    @Transactional
    public Country getCountry(String name) {
        return (Country) sessionFactory.getCurrentSession()
				.createCriteria(Country.class).add(Expression.eq("name", name))
				.uniqueResult();
    }
   
}
